// 入口文件
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/global.css'
import './assets/fonts/iconfont.css'
import axios from 'axios'
import ZkTable from 'vue-table-with-tree-grid'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)
Vue.component('tree-grid', ZkTable)

// 统一配置axios请求的根路径
axios.defaults.baseURL = 'http://liufusong.top:8888/api/private/v1/'

// 添加请求拦截器
axios.interceptors.request.use((config) => {
  // console.log(config)
  if (config.url !== 'login') {
    config.headers.Authorization = sessionStorage.getItem('token')
  }
  NProgress.start()
  return config
})
axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})

// 将axios的方法挂载到Vue原型上，所有的组件都可以直接通过this来访问
Vue.prototype.$axios = axios
Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
